<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title data-i18n="resources.title_earthquakeHeatMapLayer"></title>
    <script type="text/javascript" src="../../dist/openlayers/include-openlayers.js"></script>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%
        }

        #map {
            position: absolute;
            width: 100%;
            height: 100%;
            border: 1px solid #3473b7;
        }
    </style>
</head>

<body>
    <div id="map"></div>
    <script type="text/javascript" include="jquery,papaparse" src="../js/include-web.js"></script>
    <script type="text/javascript">
        var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
        var url = host + "/iserver/services/map-world/rest/maps/World";
        var map;
        map = new ol.Map({
            target: 'map',
            controls: ol.control.defaults({ attributionOptions: { collapsible: false } }),
            view: new ol.View({
                center: [0, 0],
                zoom: 2,
                projection: 'EPSG:4326'
            })
        });
        var iserverWorldLayer = new ol.layer.Tile({
            source: new ol.source.TileSuperMapRest({
                url: url,
                wrapX: true
            }),
            projection: 'EPSG:4326'
        });
        map.addLayer(iserverWorldLayer);


        //加载热力图
        var radius = 15, heatFeatures = [], heatMapSource, heatMapLayer;
        $.get('../data/chinaEarthquake.csv', function (csvstr) {
            var data = Papa.parse(csvstr, { skipEmptyLines: true, header: true }).data;
            for (var i = 0; i < data.length; i++) {
                if (data[i].Y <= 85) {
                    heatFeatures.push(new ol.Feature({
                        geometry: new ol.geom.Point([data[i].X, data[i].Y]),
                        Properties: { "value": data[i].level / 50 }
                    }))
                }
            };
            heatMapSource = new ol.source.HeatMap("heatMap", {
                "map": map,
                "id": "heatmap",
                "radius": radius,
                //权重
                "featureWeight": "value",
            });
            heatMapSource.addFeatures(heatFeatures);
            heatMapLayer = new ol.layer.Image({
                source: heatMapSource
            });
            map.addLayer(heatMapLayer);
        });


    </script>
</body>

</html>